import os


def get_all_files(dir):
    files = []
    list = os.listdir(dir)
    for file in list:
        path = os.path.join(dir, file)
        if os.path.isdir(path):
            files.extend(get_all_files(path))
        elif os.path.isfile(path):
            files.append(path)

    return files


def rename(dir, keyword, new_name):
    list = os.listdir(dir)
    for file in list:
        path = os.path.join(dir, file)
        if os.path.isfile(path):
            if keyword in file:
                prefix = file.replace(keyword, '')
                prefix = prefix.replace("我修的可能是假仙 ", '')
                os.rename(path, os.path.join(dir, new_name + prefix))


if __name__ == '__main__':
    print(get_all_files("G:\\Excel"))
    rename("G:\BaiduNetdiskDownload\kkkkkk", " 【闲鱼：meizu酱油君】【微信 mcsuiyue1995】", "我修的可能是假仙")

